#! /bin/bash

# This is a script to wrap smartctl output into http:// displayable form
# It requires a filename as input, and produces an file with a .html extension as output

if [ $# -ne 1 ] ; then
	echo This script requires one a file as input
	exit 1
fi

model=`grep "Device Model"  $1  | awk '{print $3}' `

# see if file name in use
let i=0
while [ -f $model-$i.html ] ; do
	let i+=1
done

filename=$model-$i
echo -e "<pre><tt>\n"    > $filename.html
cat $1                  >> $filename.html
echo -e "</tt></pre>\n" >> $filename.html

echo created file $filename.html
